import OSS from "ali-oss";

export const ossUrl = "http://management-staff.oss-cn-beijing.aliyuncs.com/"

const client = new OSS({
  // yourBucketName填写Bucket名称。
  bucket: "management-staff",
  // yourRegion填写Bucket所在地域。以华东1（杭州）为例，Region填写为oss-cn-hangzhou。
  region: "oss-cn-beijing",
  // 从环境变量中获取访问凭证。运行本代码示例之前，请确保已设置环境变量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
  accessKeyId: "LTAI5tBHMa4rZ6NUwVWz8EPb",
  accessKeySecret: "PuQ2y3mOR3OZxnvNwVyiMqCZ83pe5D",
  authorizationV4: true,
});

// 文件上传
export const fileUpload = async(name, file) => {
  try {
    const res = await client.put(name, file);
    return res
  } catch (error) {
    console.log("上传失败:",error);
  }
}
